<template>
  <div class="approvals">
    <h2>审批</h2>
    <HmUpload :before-upload="beforeUpload" :on-success="onSuccess" />
    <button @click="goOut">excel导出</button>
  </div>
</template>

<script>
import { export_json_to_excel } from '@/vendor/Export2Excel'
export default {
  methods: {
    beforeUpload(file) {
      console.log(file)
      // 作用：上传前的限制，(比如限制上传的文件大小，类型等....)
      const isLimit1k = file.size / 1024 < 1024
      if (!isLimit1k) {
        this.$message.error('最多上传1024kb的文件')
      }
      return isLimit1k
    },
    onSuccess(obj) {
      console.log(obj)
    },
    goOut() {
      export_json_to_excel({
        header: ['aaa', 'bbb'],
        data: [['111', '222']],
        filename: '导出的excel'
      })
    }
  }
}
</script>

<style></style>
